<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Send_mail {
    private $CI;
    public function __construct() {
        $this->CI =& get_instance();
        $this->CI->load->library('email');
        $config = array(
            'protocol'  => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => '465',
            'smtp_user' => 'myprints.vn@gmail.com',
            'smtp_pass' => 'myprint2014',
            'mailtype'  => 'html',
            'starttls'  => true,
            'newline'   => "\r\n"
        );
        $this->CI->email->initialize($config);
    }
    
    public function send_mail($data){ 
        $this->CI->email->from('supermouseno1@gmail.com', 'Huy Nguyen');
        $this->CI->email->to($data['mail_to']);
        $this->CI->email->subject($data['subject']);
        $this->CI->email->message($this->CI->load->view('mail/' . $data['view'], array('data' => $data['data']), TRUE));        
        $this->CI->email->send();
    }
}